package com.lin.manager.controller.login;

import com.lin.manager.common.resp.R;
import com.lin.manager.login.service.SysLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @作者: 林江
 * @创建时间: 2024/3/15
 * @功能:
 */
@Slf4j
@Api(tags = "认证管理")
@RestController
public class SysLoginController {
    @Resource
    SysLoginService sysLoginService;

    @ApiOperation("获取登录用户详情，包含角色和权限")
    @GetMapping("/getUserInfo")
    public R getUserInfo(@RequestHeader("token") String token) throws IOException {
        return R.ok(sysLoginService.getUserInfo(token));
    }

    @ApiOperation("登出")
    @GetMapping("/logout")
    public R logout() throws IOException {
        sysLoginService.logout();
        return R.ok();
    }
}
